import {search} from "../../until/db.js"
Page({
  data:{
    lists:[]
  },
  async onLoad(e){
    // console.log(e);
    var keyword = e.keyword
    wx.setNavigationBarTitle({
      title: keyword,
    })
    var result = await search("menu",keyword).catch(err=>{
      console.log(err);
    })
    // console.log(result)
    

    var lists = result.data
    lists.forEach(item=>{
      if(item.views==0){
        item.star=0
      }else if(item.views>0 && item.views<=10){
        item.star=1;
      }else if(item.views>10 && item.views<=20){
        item.star=2
      }else if(item.views>20 && item.views<=30){
        item.star=3
      }else if(item.views>30 && item.views<=40){
        item.star=4;
      }else{
        item.star=5
      }
    })

    this.setData({
      lists
    })
  }
  
})